package com.snopy.user.exception;

import com.snopy.pojo.JSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * @author snopy
 * @version 1.0.0
 * @classname CustomExceptionHandle
 * @description
 * @email 77912204@qq.com
 * @date 2020/10/17 22:47
 */
@RestControllerAdvice
public class CustomExceptionHandle {
    // 上传文件超过500k，捕获异常：MaxUploadSizeExceededException
    @ExceptionHandler(value = MaxUploadSizeExceededException.class)
    public JSONResult handlerMaxUploadFile(MaxUploadSizeExceededException exception){
        return JSONResult.errorMsg("文件上传大小不能超过500k，请压缩图片或者降低图片质量再上传！");
    }

}
